<%--
 *  File:    ItemGroupMapPop.jsp
 *  @Author: Linda Xu
 *  Date:    2005/05/17
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.  
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>
<%@ page contentType = "text/html;charset=UTF-8" %>

<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%  
   //Init param     
     Category cat = Category.getInstance("jsp.ItemGroupMapPop");    
     String privilegeCode = "10123";
     String strModuleName = "OGM";
     String strTableName = "v_itemgroup";
     String contextPath = request.getContextPath();    
     HashMap userinfo=(HashMap)session.getAttribute("userinfo");    
%>
         

<%@ include file="/inc/SessionTimeout.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title></title>  
<PageFlow:CheckPageFlow pageName="p_itemgroupsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<%@ include file="/inc/SumDiv.inc" %>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<%
        Vector itemgroupsummary=(Vector)pageContext.getAttribute("itemgroupsummary");
         if(itemgroupsummary==null)
              itemgroupsummary=new Vector();
         int i=0;
         boolean bHasChecked=false;
         String defalutItemGroupCode="";
	    String strItemGroupName="";
	    Integer intItemGroupId= new Integer(0);
	    Object strIsAll = request.getParameter("isall");
 %>
<script language="javascript">
function page_summary(actionvalue,orderbyname)
{
	  var editform = summaryPrepare(frm,actionvalue,orderbyname);
	  editform.action = "ItemGroupMapPop.jsp?<%= OvalTools.randomURL() %>";
	  editform.target = "_self";
	  isRunning = true;
	  editform.submit();  
}
function clickItemGroup(id,name,code)
{ 
  document.frm.itemgroupid.value = id;
  document.frm.itemgroupname.value = name;
  document.frm.itemgroupcode.value = code;
}
function setParentValue()
{
  if (document.frm.itemgroupid.value != "")
    opener.page_setItemGroup(document.frm.itemgroupid.value,document.frm.itemgroupname.value,document.frm.itemgroupcode.value);
  window.close();
}
function page_cancel()
{
  window.close();
}

</script>                 
</head>      
<body>
<form name="frm" method="post" action="<%=contextPath%>/Dispatcher" >     
      <input type="hidden" name="pagename" value="p_itemgroupsummary">
      <input type="hidden" name="actionname">   
      <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">  
                                                      

  <table width="100%" cellspacing="0" border="0" cellpadding="0">
    <tr> 
      <td> 
        <table width="100%" border="0" cellspacing="0">
          <%@ include file="/inc/SummarySearch.inc" %>
        </table>
        <table  border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="1" width="100%">
          <tr class="deepblue-left"> 
           	<td class="title_center"  width="5%" >&nbsp;</td>
          	<td class="title_center"  width="25%"><%=label.getLabelName("L_ItemGroupCode")%> </td>
          	<td class="title_center"  width="25%"><%=label.getLabelName("L_ItemGroupName")%> </td>
          	<td class="title_center"  ><%=label.getLabelName("L_ItemGroupDesc ")%> </td>
          </tr>  
<span id="newdetail">
          <logic:iterate id="itemids" collection="<%= itemgroupsummary %>" indexId="idx"> 
          <%
	        	  HashMap tempMap = (HashMap)pageContext.getAttribute("itemids");
	            String strIsChecked = "";
	            String strClassType="";
	            String strIsSystem="";
	            String strItemGroupCode="";
	                      strIsSystem = (String)tempMap.get("issystem"); //for issystem
	                      strItemGroupCode = (String)tempMap.get("itemgroupcode"); //for itemgroupcode

	            if(i%2 == 1)
	            {
	              	strClassType = "td-listrom";
	            }
	            else
	            {
	              	strClassType = "";
	            }
	            if(!bHasChecked)
	            {
	            	  strIsChecked = "Checked";
	               bHasChecked = true;
	               defalutItemGroupCode = (String)tempMap.get("itemgroupcode"); //for itemgroupcode
	               strItemGroupName = (String)tempMap.get("itemgroupname"); //for itemgroupname
	               intItemGroupId=(Integer)tempMap.get("itemgroupid"); //for itemgroupid
	            }
	            i++;
	        %>
 	
      <tr  onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull(strClassType)%>'"  class="<%=JspHelper.filterNull( strClassType )%>" onClick="javascript:radiotrue('id<%=JspHelper.filterNull( idx.intValue() )%>');javascript:clickItemGroup('<custom:write name="itemids" property="itemgroupid"/>','<custom:write name="itemids" property="itemgroupname" />','<custom:write name="itemids" property="itemgroupcode" />')" class="<%=JspHelper.filterNull( strClassType )%>">
            <td> 
               <input <%=JspHelper.filterNull( strIsChecked )%> type="radio"  id="id<%=JspHelper.filterNull( idx.intValue() )%>" name="ids"  value='<custom:hidden name="itemids" property="itemgroupid" colIndex="<%= idx %>"/>' class="normalradio">
            </td>          
            <td>
            		<custom:write name="itemids" property="itemgroupcode" />
            		<custom:hidden name="itemids" property="itemgroupcode"  colIndex="<%=idx%>"/>
            		<custom:hidden name="itemids" property="itemgroupid"  colIndex="<%=idx%>"/>
            		<custom:hidden name="itemids" property="issystem"  colIndex="<%=idx%>"/>
            	</td>
            <td>                
                   <custom:write name="itemids" property="itemgroupname" />                
            </td>
            <td><custom:write name="itemids" property="description" /></td>
        </tr>

          </logic:iterate>
          <input type="hidden" name="itemgroupid" value="<%=JspHelper.filterNull( intItemGroupId)%>">
          <input type="hidden" name="itemgroupcode" value="<%=JspHelper.filterNull( defalutItemGroupCode)%>">
          <input type="hidden" name="itemgroupname" value="<%=JspHelper.filterNull( strItemGroupName)%>">

</span>
              <input type="hidden" name="numrows" value='<%=JspHelper.filterNull(itemgroupsummary.size())%>'>

          		<%@ include file="/inc/SummaryAction.inc" %>
        </table>
        <table width="100%" cellspacing="0" cellpadding="0">
          <tr>
          		<td class="summary_top" ></td>
        	</tr>
          <tr> 
            <td class="td_center"> 
        <tr>
          <td class="td_center">
              <a onclick="setParentValue()"><custom:button type="1" label="L_Ok" imgsrc="ok.gif" border="0" style="width:60"/></a>        
            	 <a onclick="page_cancel()"><custom:button type="1" label="L_Cancel" imgsrc="modify.gif" border="0" style="width:60"/></a>
          </td>
        </tr>
      </table>
      </td>
    </tr>
  </table>
</form>
</body>
</html>
